home *** CD-ROM | disk | FTP | other *** search
/ Columbia Kermit / kermit.zip / newsgroups / misc.20010921-20020314 / 000287_fdc@columbia.edu_Tue Jan 8 14:32:57 EST 2002.msg < prev    next >
Text File  |  2020-01-01  |  4KB  |  123 lines

  1. Article: 13119 of comp.protocols.kermit.misc
  2. Path: newsmaster.cc.columbia.edu!news.columbia.edu!news-not-for-mail
  3. From: fdc@columbia.edu (Frank da Cruz)
  4. Newsgroups: comp.protocols.kermit.misc
  5. Subject: Re: Kermit 8 FTP scripting
  6. Date: 8 Jan 2002 14:32:47 -0500
  7. Organization: Columbia University
  8. Lines: 106
  9. Message-ID: <a1fhgv$sgj$1@watsol.cc.columbia.edu>
  10. References: <336f652d.0201081116.4cd7a675@posting.google.com>
  11. NNTP-Posting-Host: watsol.cc.columbia.edu
  12. X-Trace: newsmaster.cc.columbia.edu 1010518368 6517 128.59.39.139 (8 Jan 2002 19:32:48 GMT)
  13. X-Complaints-To: postmaster@columbia.edu
  14. NNTP-Posting-Date: 8 Jan 2002 19:32:48 GMT
  15. Xref: newsmaster.cc.columbia.edu comp.protocols.kermit.misc:13119
  16.  
  17. In article <336f652d.0201081116.4cd7a675@posting.google.com>,
  18. Shifeux <shifeux@hotmail.com> wrote:
  19. : Hello, I am writing a small kermit script using the built in ftp
  20. : client. The script works fine as far as stepping through the transfer,
  21. : but I am having problems working with the log files. I would like to
  22. : keep a detailed transaction log containing the status of the issued
  23. : commands.  For example, when the script issues the following command:
  24. :   ftp cd \%r
  25. : i would like to be able to send a line of text to the transaction log
  26. : to indicate the status of that command.  I am able to do that using
  27. : the if fail or if success in the next line of the sctipt. But for a
  28. : failure I need to exit the script rather than carry through with other
  29. : commands. My example is as follows:
  30. : ftp cd \tmp\hello\
  31. :     if success write TRANSACTION-LOG FTP Server Message:
  32. : \v(ftp_message)\13\10
  33. :     if fail write TRANSACTION-LOG FTP Server Message:
  34. : \v(ftp_message)\13\10
  35. First of all, I assume these IF FAIL commands don't have line breaks in your
  36. actual script.  If they do, of course, the script has illegal syntax.  So
  37. what you meant to write was:
  38.  
  39.   ftp cd \tmp\hello\
  40.   if success write TRANSACTION-LOG FTP Server Message: \v(ftp_message)\13\10
  41.   if fail write TRANSACTION-LOG FTP Server Message: \v(ftp_message)\13\10
  42.  
  43. Second: You can eliminate the ugly \13\10 notation as follows:
  44.  
  45.   ftp cd \tmp\hello\
  46.   if success writeln TRANSACTION-LOG FTP Server Message: \v(ftp_message)
  47.   if fail writeln TRANSACTION-LOG FTP Server Message: \v(ftp_message)
  48.  
  49. Third: You shouldn't put an IF FAIL command after an IF SUCCESS command
  50. unless you really mean to; I don't think that's what you want in this.  So:
  51.  
  52.   ftp cd \tmp\hello\
  53.   if success {
  54.       writeln TRANSACTION-LOG FTP Server Message: \v(ftp_message)
  55.   } else {
  56.       writeln TRANSACTION-LOG FTP Server Message: \v(ftp_message)
  57.   }
  58.  
  59. Fourth: Since the IF and ELSE commands are identical, you don't need
  60. the IF statement at all:
  61.  
  62.   ftp cd \tmp\hello\
  63.   writeln TRANSACTION-LOG FTP Server Message: \v(ftp_message)
  64.  
  65. Fifth: Backslash is a special character in Kermit commands.  You might need
  66. to double them in your FTP CD command:
  67.  
  68.   ftp cd \\tmp\\hello\\
  69.  
  70. Or try:
  71.  
  72.   ftp cd /tmp/hello/
  73.  
  74. which might be accepted by the server.
  75.  
  76. : I can't seem to add in an exit command to the if fail line. If i have:
  77. :     if fail exit 1 write TRANSACTION-LOG FTP Server message:
  78. : \v(ftp_message)
  79. : the transaction log is never written.
  80. :
  81. Did you give a LOG TRANSACTIONS command to open it?
  82.  
  83. The optional EXIT command arguments are (1) a number (exit status code) and
  84. (2) a message to print (not a command to execute).
  85.  
  86. : How and i string along more than
  87. : 1 command in this statement? A (,) does not do the trick.
  88. The way to group commands in an IF statement is:
  89.  
  90.   if <condition> {
  91.        command
  92.        command
  93.        ...
  94.   }
  95.  
  96. Of course you can also have an ELSE part with one or more commands:
  97.  
  98.   if <condition> {
  99.        command
  100.        command
  101.        ...
  102.   } else {
  103.        command
  104.        command
  105.        ...
  106.   }
  107.  
  108. In your case:
  109.  
  110.   if fail {
  111.        writeln TRANSACTION-LOG FTP Server message: \v(ftp_message)
  112.        exit 1
  113.   }
  114.  
  115. - Frank
  116.